import { useRequest } from 'ahooks'
import { useState } from 'react'
import request from '../../../utils/request'
export function useDetailData( detailUrl = '',) {
    const [ data, setData ] = useState({})
    const getDetailApi = params => {
        return request({
            url: detailUrl,
            data: params
        })
    }
    const { loading, run } = useRequest(getDetailApi,{
        manual: true,
        onSuccess: res =>{
            setData(res.data)
        }
    })

    const getDetailData = params => {
        run(params)
    }

    return {
        getDetailData,
        loading,
        data
    }
}
